/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t_ora_set_last_sess_phase.c                        */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/15 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../../src/module/oracle/config.h"
#include "../../test_ora_comm.h"
#include <apmtest_comm.h>
#include <oracle/comm/ora_comm.h>

extern void __ora_destroy_session(L7session_ora **pp_st_session);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

/**
 * 正确测试
 */
static void __case1(void)
{
    L7session_ora *p_st_ora_sess = test_ora_session_create();
    CU_ASSERT_PTR_NOT_NULL(p_st_ora_sess);

    ora_set_last_sess_phase(p_st_ora_sess->arr_sess_phase, APM_ORA_SESS_PHASE_OALL7);
    ora_set_last_sess_phase(p_st_ora_sess->arr_sess_phase, APM_ORA_SESS_PHASE_OOPEN);
    CU_ASSERT_EQUAL(p_st_ora_sess->arr_sess_phase[0], APM_ORA_SESS_PHASE_OOPEN);
    CU_ASSERT_EQUAL(p_st_ora_sess->arr_sess_phase[1], APM_ORA_SESS_PHASE_INIT);

    __ora_destroy_session(&p_st_ora_sess);
    CU_ASSERT_PTR_NULL(p_st_ora_sess);
}

int add_suite_ora_set_last_sess_phase(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" ora_set_last_sess_phase()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
